<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns="http://affymetrix.arabidopsis.info/NS/CriminalNetwork/1"
targetNamespace="http://affymetrix.arabidopsis.info/NS/CriminalNetwork/1"
elementFormDefault="qualified">

  <!-- import HTML schema: we use some p and br tags in some of the tags -->

  <xs:import namespace="http://www.w3.org/1999/xhtml" schemaLocation="http://www.w3.org/2002/08/xhtml/xhtml1-transitional.xsd"/>

  <!-- "xml field" types -->

  <xs:complexType name="xml-field">
    <xs:annotation>
      <xs:documentation>
        The so-called "XML fields" are made up of a series of
        parameter tags. These were intended to work (very roughly) as
        an ontology type system.
      </xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter"/>
    </xs:sequence>
  </xs:complexType>

  <xs:element name="parameter">
    <xs:annotation>
      <xs:documentation>
        parameter have name, source, value. This is somewhat similar to EAV.
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="name" type="xs:string"/>
          <xs:attribute name="source" type="xs:string"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>

  </xs:element>

  <!-- a type that allows html p and br elements and text -->

  <xs:complexType name="htmlandtext" mixed="true">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element ref="xhtml:br" />
      <xs:element ref="xhtml:p"/>
    </xs:choice>
  </xs:complexType>

  <!-- Some common elements -->

  <xs:element name="Name" type="xs:string">

    <xs:annotation>
      <xs:documentation>
        Name elements appear lots of places, and describe the name of the
        thing they are attached to.
      </xs:documentation>
    </xs:annotation>

  </xs:element>


  <xs:element name="Other" type="xml-field">

    <xs:annotation>
      <xs:documentation>
        Lots of of "things" have Other tags. These are XML fields that are a general dumping
        ground for stuff that doesn't fit anywhere into the schema.
      </xs:documentation>
    </xs:annotation>

  </xs:element>


  <!-- BioSource information -->

  <xs:element name="Source">

    <xs:annotation>
      <xs:documentation>
        The source gives information about the BioSource- the original source
        of the material used to prepare the sample. The below element are all
        based on MIAME, and describe various aspects of the sample.
      </xs:documentation>
    </xs:annotation>


    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="Organism" type="xs:string" />
        <xs:element ref="Name"/>
        <xs:element name="Alias" type="xs:string" />
        <xs:element name="StockCode" type="xs:string" />
        <xs:element name="GeneticBackground" type="xs:string" />
        <xs:element name="CellSourceType" type="xml-field" />
        <xs:element name="Sex" type="xs:string" />
        <xs:element name="Age" type="xs:string" />
        <xs:element name="GrowthConditions" type="xml-field" />
        <xs:element name="DevelopmentStage" type="xml-field" />
        <xs:element name="Tissue" type="xs:string" />
        <xs:element name="GeneticVar" type="xs:string" />
        <xs:element name="Individual" type="xs:string" />
        <xs:element name="IndivGeneChar" type="xs:string" />
        <xs:element name="Diseased" type="xs:string" />
        <xs:element name="TargetCellType" type="xs:string" />
        <xs:element name="CellLineSource" type="xs:string" />
        <xs:element name="invivoTreat" type="xml-field" />
        <xs:element name="invitroTreat" type="xml-field" />
        <xs:element name="TreatmentType" type="xs:string" />
        <xs:element name="Compound" type="xs:string" />
        <xs:element name="AdditionalOrgInfo" type="xml-field" />
        <xs:element name="SeperationTechnique" type="xml-field" />
        <xs:element ref="Other" />
      </xs:choice>
    </xs:complexType>
  </xs:element>


  <xs:element name="Extract">
    <xs:annotation>
      <xs:documentation>
        The "extract" is the RNA sample, and is made from the source. This element
        contains the Source that made the Extract, the Extraction and
        Labelling protocols, and the ExtractDetails element
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>

        <xs:element name="ExtractDetails">
          <xs:annotation>
            <xs:documentation>
              This element gives information about the extract.
            </xs:documentation>
          </xs:annotation>

          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Name" />
              <xs:element ref="Other" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="ExtractProtocol">
          <xs:annotation>
            <xs:documentation>
              This element gives information about how the extract was labelled.
            </xs:documentation>
          </xs:annotation>

          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Name" />
              <xs:element name="Method" type="xml-field" />
              <xs:element name="Type" type="xs:string" />
              <xs:element name="Amplification" type="xs:string" />
              <xs:element ref="Other" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="LabelProtocol">
          <xs:annotation>
            <xs:documentation>
              This element gives information about how the extract was labelled.
            </xs:documentation>
          </xs:annotation>

          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Name" />
              <xs:element name="AmountLabelled" type="xs:string" />
              <xs:element name="LabelName" type="xs:string" />
              <xs:element name="LabelMethod" type="xs:string" />
              <xs:element ref="Other" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element ref="Source" />

      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <!-- ResultSets and Images -->

  <xs:element name="ResultSet">
    <xs:annotation>
      <xs:documentation>
        A resultset is a collection of data
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>

        <xs:element name="NormProt">
          <xs:annotation>
            <xs:documentation>
              Information about the normalisation protocol used
            </xs:documentation>
          </xs:annotation>

          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Name" />
              <xs:element name="Strategy" type="xs:string" />
              <xs:element name="Algorithm" type="xs:string" />
              <xs:element name="ControlElements" type="xml-field" />
              <xs:element ref="Other" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="ImAnProt">
          <xs:annotation>
            <xs:documentation>
              Image Analysis Protocol details
            </xs:documentation>
          </xs:annotation>

          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Name" />
              <xs:element name="SoftwareName" type="xs:string" />
              <xs:element name="ParameterSet" type="xml-field" />
              <xs:element ref="Other" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>


        <xs:element ref="Name" />
        <xs:element name="ScaleFactor" type="xs:string" />
        <!-- always actually a xs:float, or not present -->
      </xs:sequence>
      <xs:attribute name="resultSetID" type="xs:integer" />
    </xs:complexType>
  </xs:element>



  <xs:element name="Image">

    <xs:annotation>
      <xs:documentation>
        Images have one or more resultsets, plus a scanning protocol
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element ref="Name" />

        <xs:element name="ScanProt">
          <xs:annotation>
            <xs:documentation>
              Scanning Protocol
            </xs:documentation>
          </xs:annotation>

          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Name" />
              <xs:element name="LaserPower" type="xs:string" />
              <xs:element name="Width" type="xs:string" />
              <xs:element name="Height" type="xs:string" />
              <xs:element name="XRes" type="xs:string" />
              <xs:element name="YRes" type="xs:string" />
              <xs:element name="ScannerName" type="xs:string" />
              <xs:element name="SoftwareName" type="xs:string" />
              <xs:element name="OtherParameters" type="xs:string" />
              <xs:element ref="Other" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element ref="ResultSet" />
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <!-- Slides -->

  <xs:element name="Slide">
    <xs:annotation>
      <xs:documentation>
        Slides- very important! Each slide represents one actual hybridisation
        of a sample to a microarray. Contains Extract-s hybridised to this
        array, and Image-s produced from this array. Also contains some trivia
        about the slide.
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>
        <xs:element name="SlideDetails">
          <xs:annotation>
            <xs:documentation>
              Infomation about this slide
            </xs:documentation>
          </xs:annotation>

          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Name" />
              <xs:element name="ArrayName" type="xs:string" />
              <xs:element name="ProductionDate" type="xs:string" />
              <xs:element name="HybridisedDate" type="xs:string" />
              <xs:element ref="Other" />
            </xs:sequence>
            <xs:attribute name="arraydesignid" type="xs:integer" />
          </xs:complexType>
        </xs:element>

        <xs:element name="HybrProt">
          <xs:annotation>
            <xs:documentation>
              Infomation about this slide
            </xs:documentation>
          </xs:annotation>

          <xs:complexType>
            <xs:sequence>
              <xs:element name="Solution" type="xml-field" />
              <xs:element name="BlockingAgent" type="xml-field" />
              <xs:element name="WashProcedure" type="xml-field" />
              <xs:element name="QuantityUsed" type="xml-field" />
              <xs:element name="Time" type="xs:string" />
              <xs:element name="Concentration" type="xs:string" />
              <xs:element name="Volume" type="xs:string" />
              <xs:element name="Temperature" type="xs:string" />
              <xs:element ref="Name" />
              <xs:element ref="Other" />
            </xs:sequence>
            <xs:attribute name="arraydesignID" type="xs:integer" />
          </xs:complexType>
        </xs:element>

        <xs:element name="ArrayDetails">
          <xs:annotation>
            <xs:documentation>
              Infomation about the type of microarray used
            </xs:documentation>
          </xs:annotation>

          <xs:complexType>
            <xs:sequence>
              <xs:element name="ArrayDesignName" type="xs:string" />
              <xs:element name="ArraySource" type="xs:string" />
              <xs:element name="ArrayTypeName" type="xs:string" />
              <xs:element name="SpotCount" type="xs:integer" />
            </xs:sequence>
            <xs:attribute name="ArrayDesignID" type="xs:integer" />
          </xs:complexType>
        </xs:element>

        <xs:element name="Extracts">
          <xs:annotation>
            <xs:documentation>
              Extracts associated with this slide
            </xs:documentation>
          </xs:annotation>

          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Extract" minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <!--		<xs:element name="Images">
			<xs:annotation>
			<xs:documentation>
			Images associated with this slide
			</xs:documentation>
			</xs:annotation>

			<xs:complexType>
			<xs:sequence>-->
        <xs:element ref="Image" minOccurs="0" maxOccurs="unbounded" />
        <!--			</xs:sequence>
			</xs:complexType>
		</xs:element>-->


      </xs:sequence>

      <xs:attribute name="SlideID" type="xs:integer"/>
    </xs:complexType>

  </xs:element>

  <!-- submitter -->
  <xs:element name="Submitter">

    <xs:annotation>
      <xs:documentation>
        The submitter is the person responsible for this experiment.
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>
        <xs:element name="Title" type="xs:string" />
        <xs:element name="Forename" type="xs:string" />
        <xs:element name="Initial" type="xs:string" />
        <xs:element name="Surname" type="xs:string" />
        <xs:element name="HLTitle" type="xs:string" />
        <xs:element name="HLForename" type="xs:string" />
        <xs:element name="HLInitial" type="xs:string" />
        <xs:element name="HLSurname" type="xs:string" />
        <xs:element name="Phone" type="xs:string" />
        <xs:element name="Fax" type="xs:string" />
        <xs:element name="Email" type="xs:string" />
        <xs:element name="Lab" type="xs:string" />
        <xs:element name="Institute" type="xs:string" />
        <xs:element name="Address" type="htmlandtext" />
        <xs:element name="Postcode" type="xs:string" />
        <xs:element name="Country" type="xs:string" />
        <xs:element name="URL" type="xs:string" />
        <xs:element ref="Other" />
      </xs:sequence>
    </xs:complexType>

  </xs:element>

  <xs:element name="HybrSet">
    <xs:annotation>
      <xs:documentation>
        A Hybridisation Set is a group of slides.
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>
        <xs:element name="HybrSetDetails">
          <xs:annotation>
            <xs:documentation>
              Trivia about the Hybridisation Set
            </xs:documentation>
          </xs:annotation>

          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Name" />
              <xs:element name="Group" type="xs:string"/>
              <xs:element ref="Other" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element ref="Slide" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>


  <!-- Experiment stuff -->

  <xs:element name="ExperimentDetails">
    <xs:annotation>
      <xs:documentation>
        Infomation about this experiment (abstract, etc.)
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>
        <xs:element name="ExpParams" type="xml-field" />
        <xs:element name="HybrSetDescr" type="xml-field" />
        <xs:element name="Quality"  type="xml-field" />
        <xs:element ref="Name" />
        <xs:element name="Description"  type="htmlandtext"/>
        <xs:element name="Type" type="xs:string"/>
        <xs:element name="Citations" type="xml-field" />
        <xs:element ref="Other" />
        <xs:element name="SubmittedDate" type="xs:string" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>


  <xs:element name="Experiment">

    <xs:annotation>
      <xs:documentation>
        Root tag that describes the experiment as a whole. Contains
        the Experiment details, the Hybridisation Sets, and the
        Submitter who sent the experiment.
      </xs:documentation>
    </xs:annotation>


    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Submitter" />
        <xs:element ref="ExperimentDetails" />

        <xs:element ref="HybrSet" minOccurs="0" maxOccurs="unbounded"/>

      </xs:sequence>
      <xs:attribute name="ExperimentID" type="xs:integer" />
    </xs:complexType>
  </xs:element>



  <xs:element name="ExperimentLite">
    <xs:annotation>
      <xs:documentation>
        An ExperimentLite tag is like an Experiment only without the HybrSets
        (and by extension most of the experimental details). Used in
        the experiment browse page.
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Submitter" />
        <xs:element ref="ExperimentDetails" />
      </xs:sequence>
      <xs:attribute name="experimentID" type="xs:integer" />
      <xs:attribute name="score" type="xs:integer" />
    </xs:complexType>


  </xs:element>


  <!-- Page Specific Tags -->

  <xs:element name="ExperimentList">
    <xs:annotation>
      <xs:documentation>
        An Experiment List is a list of ExperimentLite-s. Used on the
        oldexperimentbrowse.pl page.
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>
        <xs:element ref="ExperimentLite" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>


  <!-- Things that don't work with this schema: GeneSwinger -->

  <!-- PreDownload schema. If you are writing applications to use the
website in a "Web Services" style, you won't need this page. But I'll
include this for completeness -->

  <xs:element name="pd">
    <xs:annotation>
      <xs:documentation>
        Root element for the pre-download page
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>
        <xs:element name="hiddenlinks">

          <xs:annotation>
            <xs:documentation>
              A list of XHTML form input tags that are hidden.
            </xs:documentation>
          </xs:annotation>

          <xs:complexType>
            <xs:sequence>
              <xs:element ref="xhtml:input" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="descstring" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              Description of what you are downloading
            </xs:documentation>
          </xs:annotation>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <!-- That was exciting wasn't it -->

  <!-- Lists of slides -->

  <xs:element name="SlideList">

    <xs:annotation>
      <xs:documentation>
        A list of slides.
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Slide" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>


  </xs:element>


  <!-- Root element for slide search -->

  <xs:element name="searchSlideList">

    <xs:annotation>
      <xs:documentation>
        Root element for slide search
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>
        <xs:element ref="SlideList"/>
      </xs:sequence>
    </xs:complexType>

  </xs:element>


  <!-- 
Spot History 

This pages uses frames- one of the pages is just a SlideList- see
earlier descriptions. Much of the Spot History is very hard to program
with- the XML is heavily tailored to the needs of the website.


THIS SCHEMA DOES NOT SUPPORT the looking up probes aspect of the Spot History.


-->

  <xs:element name="dampsquib">
    <xs:annotation>
      <xs:documentation>
        dampsquib elements elements appear lots of places, and are basically
        an error message. The fact that it has a silly name reveals that I
        never really intended the public to see it.
      </xs:documentation>
    </xs:annotation>

    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="BlastView"/>
        <xs:element name="ArabidopsisEnsembl"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:element name="ProbeInfo">
    <xs:complexType>
      <xs:sequence>

        <xs:element name="EnsemblLink">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute name="StableID" type="xs:string" />
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>

      </xs:sequence>
      <xs:attribute name="Probe" type="xs:string" />
      <xs:attribute name="ArrayName" type="xs:string" />
    </xs:complexType>

  </xs:element>


  <xs:element name="sh2">

    <xs:annotation>
      <xs:documentation>
        Root element for slide search. There used to be a sh element, hence
        the name. This element really isn't very usable for third-parties-
        which is probably a problem. There are lots of different possiblities
        for the contents of this element depending on what input is supplied
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:choice>
        <xs:element ref="dampsquib" />
        <!--An error of some sort  -->
        <xs:element ref="xhtml:p" />
        <!-- An error about no data being found -->

        <xs:element name="graphbox">
          <!-- If the graphbox is supplied, we have a successful spot history -->


          <xs:complexType>
            <xs:sequence>
              <xs:element ref="ProbeInfo" />

              <xs:element name="htmlsection">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element ref="xhtml:map" />
                    <xs:element ref="xhtml:img" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>



            </xs:sequence>
          </xs:complexType>
        </xs:element>


      </xs:choice>

    </xs:complexType>

  </xs:element>


  <!-- Super Search (keyword support) support -->

  <xs:element name="searchResult">

    <xs:annotation>
      <xs:documentation>
        A Root Element for the Super Search. Simply contains a list of Experiment Lite objects
      </xs:documentation>
    </xs:annotation>

    <xs:complexType>
      <xs:sequence>
        <xs:element ref="ExperimentLite" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
    </xs:complexType>

  </xs:element>

</xs:schema>
